package com.xu.mapper;

import com.xu.pojo.Evaluate;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface EvaluateMapper {

    @Insert("insert into bread.evaluate (uid,oid,evaluate) " +
            "values (#{uid},#{oid},#{evaluate})")
    int insertEvaluate(Evaluate evaluate);

    //四表联查 评价表->订单表->产品表->用户表
    @Select("select * from evaluate JOIN `order` o ON evaluate.oid = o.id JOIN users u ON o.userid = u.uid JOIN product p ON o.pid = p.id")
    List<Evaluate> queryAllEvaluate();

    @Select("select * from evaluate JOIN `order` o ON evaluate.oid = o.id JOIN users u ON o.userid = u.uid JOIN product p ON o.pid = p.id where pid=#{pid}")
    List<Evaluate> queryEvaluateByPid(int pid);
}
